using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Verse;



namespace Verse.AI{
public static class Toils_General
{
	public static Toil Wait( int ticks )
	{
		Toil toil = new Toil();
		toil.initAction = ()=>
			{
				toil.actor.pather.StopDead();
			};
		toil.defaultCompleteMode = ToilCompleteMode.Delay;
		toil.defaultDuration = ticks;
		return toil;
	}

	public static Toil RemoveDesignationsOnThing( TargetIndex ind, DesignationDef def )
	{
		Toil toil = new Toil();
		toil.initAction = ()=>
			{
				toil.actor.Map.designationManager.RemoveAllDesignationsOn( toil.actor.jobs.curJob.GetTarget(ind).Thing );
			};
		return toil;

	}

	public static Toil ClearTarget( TargetIndex ind )
	{
		Toil toil = new Toil();
		toil.initAction = ()=>
			{
				toil.GetActor().CurJob.SetTarget(ind, null);
			};
		return toil;
	}

	public static Toil PutCarriedThingInInventory()
	{
		Toil toil = new Toil();
		toil.initAction = ()=>
			{
				var actor = toil.GetActor();
				if( actor.carryTracker.CarriedThing != null )
				{
					if( actor.inventory.innerContainer.TryAdd( actor.carryTracker.CarriedThing ) )
						actor.carryTracker.innerContainer.Clear();
					else
					{
						Thing unused;
						actor.carryTracker.TryDropCarriedThing(actor.Position, actor.carryTracker.CarriedThing.stackCount, ThingPlaceMode.Near, out unused );
					}
				}
			};
		return toil;
	}
}
}

